package org.lan.jdbc.configuration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Properties;

/**
 * 该类封装了读取配置文件中的属性的操作
 * <p>
 * 2016/8/5.
 *
 * @author jiahua-lan
 */
public final class ConfigurationHelper {

    private final static Logger LOGGER = LoggerFactory.getLogger(ConfigurationHelper.class);

    private static Properties configuration = new Properties();


    static {
        try {
            configuration.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(Configuration.CONFIGURATION_FILE));
        } catch (IOException e) {
            LOGGER.error("Can't find the " + Configuration.CONFIGURATION_FILE, e);
        }
    }

    public static String getDRIVER() {
        return configuration.getProperty(Configuration.JDBC_DRIVER);
    }

    public static String getPASSWORD() {
        return configuration.getProperty(Configuration.JDBC_PASSWORD);
    }

    public static String getURL() {
        return configuration.getProperty(Configuration.JDBC_URL);
    }

    public static String getUSERNAME() {
        return configuration.getProperty(Configuration.JDBC_USERNAME);
    }
}
